package com.hqyj.crmdemo.controller;

import com.hqyj.crmdemo.annotation.Auth;
import com.hqyj.crmdemo.entity.Report;
import com.hqyj.crmdemo.service.ICustmerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@CrossOrigin
@RequestMapping("rep")
public class ReportController {
    @Autowired
    ICustmerService service;

    //1.统计等级
    @Auth
    @RequestMapping("/countByLevel")
    public Map<String,Object> countByLevel(){
        Map<String,Object> map=new HashMap<>();
        List<String> listItem=new ArrayList<>();
        List<Integer> listCount=new ArrayList<>();
        List<Report> reports=service.countByLevel();
        for (Report report : reports) {
            listItem.add(report.getItem());
            listCount.add(report.getCount());
        }

        map.put("item",listItem);
        map.put("count",listCount);
        return map;
    }
}
